﻿
//创建Feedback
function CreateFeedback(list) {
    if (!list) {
        return false;
    };
    var len = list.length;
    var url = getAppHomeUrl() + '/customapi/SaveDocument';
    var formAlias = 'ProjectFeedback';
    list.forEach(function (item) {
        var postdata = {
            FormAlias: formAlias,
            UserName: staffInfo.StaffName,
            UserId: staffInfo.StaffCode,
            Message: '',
            Data: item
        };
        $.ajax({
            url: url,
            type: 'post',
            data: postdata,
            async: false,
            success: function (res) {
                console.log(res);
            }
        });
    });
};

function UpdateFeedback(list) {
    if (!list) {
        return false;
        $('#myModal').modal('hide');
    };
    var url = getAppHomeUrl() + '/customapi/BatchUpdateDocsList';
    var len = list.length;
    var items = [];
    for (var i = 0; i < len; i++) {
        var obj = {};
        obj.Token = '';
        var docids = [];
        docids.push(list[i].id);
        obj.DocIds = docids;
        obj.FieldsValue = list[i];
        obj.ActionCode = '';
        obj.EntityName = 'ProjectFeedback';
        obj.StaffId = staffInfo.StaffCode;
        obj.StaffName = staffInfo.StaffName;
        obj.CurrentUserRole = [];
        obj.ActionMessage = '',
        obj.UpdateWorkflowArgs = false;
        obj.Items = null;
        items.push(obj);
    };
    var data = {
        Token: '',
        DocIds: '',
        FieldsValue: '',
        ActionCode: '',
        EntityName: '',
        StaffId: '',
        StaffName: '',
        CurrentUserRole: '',
        ActionMessage: '',
        UpdateWorkflowArgs: false,
        Items: items
    };
    console.log(data);
    $.ajax({
        url: url,
        data: JSON.stringify(data),
        type: 'post',
        contentType: 'application/json',
        success: function (res) {
            debugger;
            console.log(res);
            setTimeout(function () {
                AppDesign.Document.endLoading();
                if (res && res.StatusCode == 200) {
                    //todo sth
                    $('#myModal').modal('hide');
                };
            }, 1500)
        }
    });
};